<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
      <el-form-item label="客户名称" prop="purchaserName">
        <el-input v-model="queryParams.purchaserName" placeholder="请输入客户名称" clearable
          style="width: 240px" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="客户编号" prop="businessCode">
        <el-input v-model="queryParams.businessCode" placeholder="请输入客户编号" clearable
          style="width: 240px" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="付款流水号" prop="receivableNo">
        <el-input v-model="queryParams.receivableNo" placeholder="请输入付款流水号" clearable
          style="width: 240px" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="登录账号" prop="username">
        <el-input v-model="queryParams.username" placeholder="请输入登录账号" clearable
          style="width: 240px" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="支付时间">
        <el-date-picker v-model="payDateRange" style="width: 240px" value-format="yyyy-MM-dd" clearable
          type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="创建时间">
        <el-date-picker v-model="dateRange" style="width: 240px" value-format="yyyy-MM-dd" clearable
          type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索
        </el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table border v-loading="loading" :data="orderList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" />
      <el-table-column :label="columns[0].label" :prop="columns[0].prop"
        :show-overflow-tooltip="true" :width="columns[0].width" v-if="columns[0].visible"
        align="left" />
      <el-table-column :label="columns[1].label" :prop="columns[1].prop"
        :show-overflow-tooltip="true" :width="columns[1].width" v-if="columns[1].visible"
        align="left" />
      <el-table-column :label="columns[2].label" :prop="columns[2].prop"
        :show-overflow-tooltip="true" :width="columns[2].width" v-if="columns[2].visible"
        align="left" />
      <el-table-column :label="columns[3].label" :prop="columns[3].prop"
        :show-overflow-tooltip="true" :width="columns[3].width" v-if="columns[3].visible"
        align="left" />
      <el-table-column :label="columns[4].label" align="left" :prop="columns[4].prop"
        :width="columns[4].width">
      </el-table-column>
      <el-table-column :label="columns[5].label" align="center" :prop="columns[5].prop"
        :width="columns[5].width">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.pay_way" :value="scope.row.rechargeWay" />
        </template>
      </el-table-column>
      <el-table-column :label="columns[6].label" align="center" :prop="columns[6].prop"
        :width="columns[6].width">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.order_pay_status" :value="scope.row.payStatus" />
        </template>
      </el-table-column>
      <el-table-column :label="columns[7].label" align="center" :prop="columns[7].prop"
        :width="columns[7].width">
      </el-table-column>
      <el-table-column :label="columns[8].label" align="center" :prop="columns[8].prop"
        :width="columns[8].width">
      </el-table-column>
      <el-table-column :label="columns[9].label" align="center" :prop="columns[9].prop"
        :width="columns[9].width">
      </el-table-column>
      <el-table-column :label="columns[10].label" align="center" :prop="columns[10].prop"
        :width="columns[10].width">
      </el-table-column>
      <el-table-column :label="columns[11].label" align="center" :prop="columns[11].prop"
        :width="columns[11].width">
      </el-table-column>
      <!--
      <el-table-column label="操作" align="center" fixed="right">
        <template slot-scope="scope">
          <el-button @click="deleteClick(scope.row.id)" size="small" v-hasPermi="['purchaser:member:remove']"> 删除 </el-button>
        </template>
      </el-table-column>
      -->
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize" @pagination="getList" />

  </div>
</template>

<script>
import { rechargePage } from "@/api/purchaser/recharge";

export default {
  name: "recharge",
  dicts: ["order_pay_status","pay_way"],
  data () {
    return {
      // 遮罩层
      loading: true,
      openPromotionFlag: false,
      imgForm: [],
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 订单表格数据
      orderList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层（数据权限）
      openDataScope: false,
      // 日期范围
      payDateRange: [],
      // 日期范围
      dateRange: [],
      // 列信息
      columns: [
        { key: 0, label: `ID`, prop: "id", width: 175, visible: true },
        { key: 1, label: `客户名称`, prop: "purchaserName", width: 200, visible: true },
        { key: 2, label: `客户编号`, prop: "businessCode", width: 100, visible: true },
        { key: 3, label: `联系电话`, prop: "mobile", width: 100, visible: true },
        { key: 4, label: `登录账号`, prop: "username", width: 150, visible: true },
        { key: 5, label: `支付方式`, prop: "rechargeWay", width: 80, visible: true },
        { key: 6, label: `支付状态`, prop: "payStatus", width: 80, visible: true },
        { key: 7, label: `充值金额`, prop: "rechargeMoney", width: 80, visible: true, },
        { key: 8, label: `付款流水号`, prop: "receivableNo", width: 240, visible: true, },
        { key: 9, label: `充值后余额`, prop: "memberWallet", width: 100, visible: true, },
        { key: 10, label: `支付时间`, prop: "payTime", width: 160, visible: true },
        { key: 11, label: `创建时间`, prop: "createTime", width: 160, visible: true }
      ],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        username: '',
        outOrderNo: '',
        username: '',
        memberName: '',
        purchaserName: '',
        businessCode: '',
        paramMap: {},
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        promotionPrice: [
          { required: true, message: "促销价格不能为空", trigger: "blur" }
        ],
        roleKey: [
          { required: true, message: "权限字符不能为空", trigger: "blur" }
        ],
        roleSort: [
          { required: true, message: "角色顺序不能为空", trigger: "blur" }
        ]
      }
    };
  },
  created () {
    this.getList();
  },
  methods: {
    /** 查询采购商账号列表 */
    getList () {
      this.loading = true;
      this.queryParams = this.addDateRangeWithMap(this.queryParams, this.payDateRange, "PayTime");
      rechargePage(this.addDateRangeWithMap(this.queryParams, this.dateRange, "CreateTime")).then(response => {
        this.orderList = response.rows;

        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery () {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery () {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange (selection) {
      this.ids = selection.map(item => item.roleId);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
    /** 导出按钮操作 */
    handleExport () {
      this.download(
        "purchaser/purchaser/export",
        {
          ...this.queryParams
        },
        `采购商列表_${this.parseTime(new Date().getTime(), "{y}-{m}-{d}_{h}:{i}:{s}")}.xlsx`
      );
    }
  }
};
</script>

<style lang="scss" scoped>
::v-deep .el-dialog {
  top: 0;
  .list {
    display: flex;
    flex-flow: row wrap;
    .item {
      display: flex;
      flex-flow: row wrap;
      border: 1px solid #f5f5f5;
      padding: 5px;
      img {
        width: 200px;
        height: 200px;
      }
      .imgEnlarge {
        width: 700px;
        height: 700px;
        position: absolute;
        z-index: 111;
        top: 0;
      }
      .status {
        display: flex;
        flex-flow: column nowrap;
        p {
          padding: 0 10px;
        }
        .el-select {
          width: 150px;
          margin: 5px 10px 10px;
        }
        textarea {
          width: 150px;
          height: 50px;
          resize: none;
          margin: 0 10px;
          outline: none;
        }
        .el-button {
          width: 150px;
          margin: 10px 10px 0 10px;
        }
      }
    }
  }
}
</style>
